package com.font.web.zhongyao;



import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.api.ApiController;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.font.bean.Bing;
import com.font.bean.ciyun;
import com.font.bean.result.Result;
import com.font.service.BingService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * (Bing)表控制层
 *
 * @author makejava
 * @since 2023-08-15 13:57:29
 */
@RestController
@RequestMapping("bing")
public class BingController  {
    /**
     * 服务对象
     */
    @Resource
    private BingService bingService;


    @RequestMapping("list")
    public Result selectAll() {
        return Result.success(bingService.list());
    }

    @RequestMapping("ciyunlist")
    public Result ciyunlist() {
        return Result.success(bingService.ciyunlist());
    }

    @RequestMapping("ciyunlist2")
    public Result ciyunlist2() {
        return Result.success(bingService.ciyun2list());
    }

    @RequestMapping("ciyunlist4")
    public Result ciyunlist4() {
        List<ciyun> ciyuns = bingService.ciyun4list();
        List<String> names = ciyuns.stream().map(item -> item.getName()).collect(Collectors.toList());
        List<String> values = ciyuns.stream().map(item -> item.getValue()).collect(Collectors.toList());
        Map<String, Object> map = new HashMap<>();
        map.put("names",names);
        map.put("values",values);
        return Result.success(map);
    }

    @RequestMapping("counts")
    public Result counts() {
        return Result.success(bingService.counts());
    }
}

